import logging

from config import URL
import requests

ses = requests.session()


class OpenAccountApi:

    def __init__(self, session):
        self.ses = session

    # 实名认证接口
    def realname(self, realname_v, card_id_v):
        # 实现接口请求，获取响应结果
        # 将响应体的数据打印到日志
        # 封装方法的返回
        url = URL + "/member/realname/approverealname"
        form_data = {"realname": realname_v, "card_id ": card_id_v}
        resp = self.ses.post(url=url, data=form_data, files={"x": "y"})
        # logging.info(f"实名认证接口的响应体数据{resp.json()}")
        return resp

    # 开户接口
    def open_account(self):
        url = URL + "/trust/trust/register"
        resp = self.ses.post(url=url)
        # logging.info(f"开户接口的响应体数据{resp.json()}")
        return resp

    # 第三方开户接口
    def third_open_account(self, url, form_dict):
        resp = self.ses.post(url=url, data=form_dict)
        # logging.info(f"第三方开户接口的响应体数据{resp.text}")
        return resp


if __name__ == '__main__':
    a = OpenAccountApi(ses)
    resp = a.realname("张小白", "110101200503074858")
    print(resp.json())
    print("=" * 50)

    resp=a.open_account()
    print(resp.json())
    print("=" * 50)
